home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
VS_804.ARJ
/
ERRORSYS.PRG
< prev
next >
Wrap
Text File
|
1991-12-03
|
10KB
|
288 lines
* Filename......: ErrorSys.Prg
*
* Author........: Vernon E. Six, Jr.
*
* Last Update...: Tue 12-03-1991 12:13:59
*
* Notice........: Copyright (c) 1991 by Vernon E. Six, Jr.
* All Rights Reserved World Wide
*
* Dialect.......: Clipper v5.01
*
* Compile as....: Clipper ErrorSys /n/w/b/a
#include "SETCURS.CH"
#include "INKEY.CH"
#include "ERROR.CH"
#include "FILEIO.CH"
#include "VERNSIX.CH"
*******************
PROCEDURE ErrorSys
Errorblock( { | o_Error | LogError(o_Error) } )
*******************
STATIC FUNCTION LogError( o_Error )
*****
* Log errors to disk
*****
LOCAL c_FileName := "Error.Log"
LOCAL c_OutStr
LOCAL c_Screen := SaveScreen( 0, 0, MaxRow(), MaxCol() )
LOCAL c_SubStr
LOCAL n_Cntr
LOCAL n_Handle
LOCAL n_Range
LOCAL n_Start
LOCAL x, y, i
//
// by default, division by zero is zero
//
IF ( o_Error:genCode == EG_ZERODIV )
RETURN(0)
ENDIF
//
// for network open error, set NETERR() and subsystem default
//
IF ( o_Error:genCode == EG_OPEN .AND. ;
o_Error:osCode == 32 .AND. ;
o_Error:canDefault )
NetErr(.T.)
RETURN(.F.)
ENDIF
//
// for lock error during APPEND BLANK, set NETERR() and subsystem default
//
IF ( o_Error:genCode == EG_APPENDLOCK .AND. o_Error:canDefault )
NetErr(.T.)
RETURN(.F.)
ENDIF
//
// Let the user know that something has hit the fan
//
VS_Alert( {"","A serious error has occurred. Please check " + ;
c_FileName,""}, {" Ok "}, 3 )
//
// Append to the file if it already exists, otherwise create a new one
//
IF .NOT. FILE(c_FileName)
n_Handle := FCREATE( c_FileName, FC_NORMAL )
ELSE
n_Handle := FOPEN( c_FileName, FO_READWRITE + FO_EXCLUSIVE )
ENDIF
//
// Scream and holler if the file could not be opened!
//
IF FERROR() != 0
VS_NewScrn()
VS_Alert( {"",PADC("Due to an error, information was not",40), ;
PADC("written to "+c_FileName,40), "" }, ;
{ " Ok " }, 3 )
ELSE
//
// Go to the end of the file
//
FSEEK( n_Handle, 0, FS_END )
FWriteLine( n_Handle, PADR("═══ Error Log File ", 79, "═" ) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "Error Occurred In: " + PROCNAME(2) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, " Date: " + DTOC( DATE() ) )
FWriteLine( n_Handle, " Time: " + TIME() )
FWriteLine( n_Handle, " Available Memory: " + VS_Cvt2Str( MEMORY(0) ) )
FWriteLine( n_Handle, " Current Area: " + VS_Cvt2Str( SELECT() ) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, PADR( "─── Internal Error Handling Information ", 79, "─" ) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "Clipper Error#: " + VS_Cvt2Str( o_Error:genCode ) )
FWriteLine( n_Handle, "Subsystem call: " + o_Error:subsystem )
FWriteLine( n_Handle, " System code: " + VS_Cvt2Str( o_Error:subcode ) )
FWriteLine( n_Handle, "Default Status: " + VS_Cvt2Str( o_Error:candefault ) )
FWriteLine( n_Handle, " Filename: " + o_Error:filename )
FWriteLine( n_Handle, " Description: " + o_Error:description )
FWriteLine( n_Handle, " Operation: " + o_Error:operation )
FWriteLine( n_Handle, "DOS Error Code: " + VS_Cvt2Str( o_Error:oscode ) )
FWrite( n_Handle, " Trace Through: " )
x := 1
DO WHILE !EMPTY( PROCNAME(++x) )
FWriteLine( n_Handle, PADR(PROCNAME(x), 20) + ": " + ;
PADR(PROCLINE(x), 20) )
FWrite( n_Handle, SPACE(16) )
ENDDO
FWrite( n_Handle, CHR(13)+CHR(10) )
*══════════════════════════════════════════════════════════*
IF VALTYPE( o_Error:args ) == "A"
FWrite( n_Handle, " Arguments: " )
FOR x = 1 TO LEN( o_Error:args )
FWriteLine( n_Handle, STRZERO(x,3) + ": " + VS_Cvt2Str( o_Error:args[x] ) )
NEXT x
FWrite( n_Handle, CHR(13)+CHR(10) )
ENDIF
*══════════════════════════════════════════════════════════*
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "┌"+PADR("─── Video Screen Dump ",80,"─")+"┐" )
n_Start := 1
n_Range := (MAXCOL()+1)*2
FOR x = 1 TO MAXROW()
c_SubStr := SUBSTR(c_Screen, n_Start, n_Range )
FWrite( n_Handle, "│" )
FOR y = 1 to n_Range STEP 2
FWrite( n_Handle, SUBSTR(c_SubStr, y, 1) )
NEXT
FWriteLine( n_Handle, "│" )
n_Start += n_Range
NEXT
FWriteLine( n_Handle, "└"+REPLICATE("─",79)+"┘" )
*══════════════════════════════════════════════════════════*
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, PADR( "─── Detailed Work Area Items ", 79, "─" ) )
FWriteLine( n_Handle, "" )
FOR n_Cntr = 1 TO 250
IF !EMPTY( ALIAS(n_Cntr) )
SELECT( n_Cntr )
FWriteLine( n_Handle, " Work Area No.: " + VS_Cvt2Str( SELECT() ) )
FWriteLine( n_Handle, " Alias Name: " + ALIAS() )
FWriteLine( n_Handle, " Current Recno.: " + VS_Cvt2Str( RECNO() ) )
FWriteLine( n_Handle, " Current Filter: " + dbFilter() )
FWriteLine( n_Handle, " Relation Exp.: " + dbRelation() )
FWriteLine( n_Handle, " Index Order: " + VS_Cvt2Str( INDEXORD() ) )
FWriteLine( n_Handle, " Active Key: " + INDEXKEY( INDEXORD() ) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "Current Record..." )
FWriteLine( n_Handle, "" )
FOR i = 1 TO FCOUNT()
FWriteLine( n_Handle, PADR(FieldName(i),14) + ": " + VS_Cvt2Str( FieldGet(i) ) )
NEXT i
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, "" )
ENDIF
NEXT n_Cntr
FWriteLine( n_Handle, PADC( " Environmental Information ", 79, "-" ) )
FWriteLine( n_Handle, "" )
FWriteLine( n_Handle, " Exact is: " + VS_Cvt2Str( SET(_SET_EXACT ), .T. ) )
FWriteLine( n_Handle, " Fixed is: " + VS_Cvt2Str( SET(_SET_FIXED ), .T. ) )
FWriteLine( n_Handle, "Decimals is at: " + VS_Cvt2Str( SET(_SET_DECIMALS ) ) )
FWriteLine( n_Handle, "Path is set to: " + VS_Cvt2Str( SET(_SET_PATH ) ) )
FWriteLine( n_Handle, " Default is at: " + VS_Cvt2Str( SET(_SET_DEFAULT ) ) )
FWriteLine( n_Handle, " Epoch is: " + VS_Cvt2Str( SET(_SET_EPOCH ) ) )
FWriteLine( n_Handle, "Date Format at: " + VS_Cvt2Str( SET(_SET_DATEFORMAT) ) )
FWriteLine( n_Handle, " Alternate is: " + VS_Cvt2Str( SET(_SET_ALTERNATE ), .T. ) )
FWriteLine( n_Handle, " Alter File is: " + VS_Cvt2Str( SET(_SET_ALTFILE ) ) )
FWriteLine( n_Handle, " Console is: " + VS_Cvt2Str( SET(_SET_CONSOLE ), .T. ) )
FWriteLine( n_Handle, " Margin is set: " + VS_Cvt2Str( SET(_SET_MARGIN ) ) )
FWriteLine( n_Handle, " Printer is: " + VS_Cvt2Str( SET(_SET_PRINTER ), .T. ) )
FWriteLine( n_Handle, " Printer File: " + VS_Cvt2Str( SET(_SET_PRINTFILE ) ) )
FWriteLine( n_Handle, " Device is at: " + VS_Cvt2Str( SET(_SET_DEVICE ) ) )
FWriteLine( n_Handle, " Bell is: " + VS_Cvt2Str( SET(_SET_BELL ), .T. ) )
FWriteLine( n_Handle, " Confirm is: " + VS_Cvt2Str( SET(_SET_CONFIRM ), .T. ) )
FWriteLine( n_Handle, "Delimiters are: " + VS_Cvt2Str( SET(_SET_DELIMITERS), .T. ) )
FWriteLine( n_Handle, " Delimit Chars: " + VS_Cvt2Str( SET(_SET_DELIMCHARS) ) )
FWriteLine( n_Handle, " Escape is set: " + VS_Cvt2Str( SET(_SET_ESCAPE ), .T. ) )
FWriteLine( n_Handle, " Intensity is: " + VS_Cvt2Str( SET(_SET_INTENSITY ), .T. ) )
FWriteLine( n_Handle, " Scoreboard is: " + VS_Cvt2Str( SET(_SET_SCOREBOARD), .T. ) )
FWriteLine( n_Handle, " Wrap is set: " + VS_Cvt2Str( SET(_SET_WRAP ), .T. ) )
FWriteLine( n_Handle, " Message Line: " + VS_Cvt2Str( SET(_SET_MESSAGE ) ) )
FWriteLine( n_Handle, "Message Center: " + VS_Cvt2Str( SET(_SET_MCENTER ), .T. ) )
FWriteLine( n_Handle, " Exclusive is: " + VS_Cvt2Str( SET(_SET_EXCLUSIVE ), .T. ) )
FWriteLine( n_Handle, " Softseek is: " + VS_Cvt2Str( SET(_SET_SOFTSEEK ), .T. ) )
FWriteLine( n_Handle, " Unique is: " + VS_Cvt2Str( SET(_SET_UNIQUE ), .T. ) )
FWriteLine( n_Handle, " Deleted is: " + VS_Cvt2Str( SET(_SET_DELETED ), .T. ) )
FWriteLine( n_Handle, "" )
FCLOSE( n_Handle )
ENDIF
ERRORLEVEL( 1 )
CLEAR SCREEN
dbCloseAll()
QUIT
RETURN( .F. )
*** EOF: LogError() *********************************************************